package fina2.dcs.common.security;

import java.util.List;

public class UserUtil {
	private UserUtil() {

	}

	public static UserType getUserType(String username, List<String> permissions) {
		UserType userType = null;
		if (username.toLowerCase().trim().equals("sa")) {
			userType = UserType.ADMINISTRATOR;
		} else {
			boolean isExternal = (permissions.contains("fina2.web.external.user")) ? true : false;
			boolean isInternal = (permissions.contains("fina2.web.internal.user")) ? true : false;
			if ((isExternal && isInternal)||((isInternal)&&(!isExternal)))
				userType = UserType.INTERNAL;
			if (isExternal && (!isInternal))
				userType = UserType.EXTERNAL;
		}
		return userType;
	}
}
